home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / LITTLE / BMSRC.ZIP / TEXTURES.S < prev    next >
Encoding:
Text File  |  1996-11-23  |  20.2 KB  |  716 lines

  1. *=======================================================*
  2. *    Texture module: latest update 25/03/96        *
  3. *=======================================================*
  4. *    Process, reformat, build & manage textures    *
  5. *=======================================================*
  6.  
  7. max_hash    =    4096        ; maximum number of hash entries
  8. max_textures    =    512        ; maximum number of textures in WAD
  9. max_graphics    =    2048        ; maximum number of textures in WAD
  10.  
  11. max_patches    =    72        ; maximum patches per texture
  12.  
  13. ;sky_colour    =    216        ; hack for sky colour
  14.  
  15. sky_colour    =    56        ; hack for sky colour
  16.  
  17. ;sky_colour    =    211        ; hack for sky colour
  18. upper_sky_lum    =    180
  19. upper_sky_dist    =    -64
  20. lower_sky_lum    =    180
  21. lower_sky_dist    =    64
  22.  
  23. texcode_none    =    -1
  24. texcode_sky    =    -2
  25. texcode_qalpha    =    -3
  26.  
  27. *-------------------------------------------------------*
  28. *    Read & convert texture resource directories    *
  29. *-------------------------------------------------------*
  30. init_textures:
  31. *-------------------------------------------------------*
  32. *    Set up list & resource pointers            *
  33. *-------------------------------------------------------*
  34.     move.l        #graphics_space,graphics_array
  35.     move.l        #graphics_space,floating_array
  36.     move.l        #texture_space,texture_array
  37.     move.l        #pnamelist_space,pnamelist_array
  38.     clr.w        graphics_count
  39.     clr.w        flat_count
  40.     clr.w        texture_count
  41.     sf        textures_present
  42. *-------------------------------------------------------*
  43. *    Remove unwanted sidedef textures from sky    *
  44. *-------------------------------------------------------*
  45. ;    bsr        fix_sky_textures
  46. *-------------------------------------------------------*
  47. *    Patch alpha textures                *
  48. *-------------------------------------------------------*
  49.     bsr        patch_alpha_textures
  50. *-------------------------------------------------------*
  51. *    Replace flat texture references with indexes    *
  52. *-------------------------------------------------------*
  53.     move.l        floating_array,flatlist_array
  54.     bsr        replace_flats
  55. *-------------------------------------------------------*
  56. *    Read texture directory structures        *
  57. *-------------------------------------------------------*
  58.     move.l        floating_array,texturelist_array
  59.     bsr        read_pnames
  60.     Cconws        #ascii_readtex1
  61.     lea        ascii_texture1,a0
  62.     bsr        add_textures
  63.     Cconws        #ascii_readtex2
  64.     lea        ascii_texture2,a0
  65.     bsr        add_textures
  66.     tst.b        textures_present
  67.     bne        .cont
  68.     Cconws        #ascii_err_notex
  69.     bra.s        .go
  70. *-------------------------------------------------------*
  71. *    Build hash table for textures            *
  72. *-------------------------------------------------------*
  73. .cont:    bsr        build_texture_hash
  74. *-------------------------------------------------------*
  75. *    Find sky textures                *
  76. *-------------------------------------------------------*
  77.     lea        ascii_sky1,a0
  78.     bsr        find_texture_index
  79.     move.w        d0,sky1_index
  80.     bmi.s        .n1
  81.     move.w        d0,current_sky
  82. .n1:    lea        ascii_sky2,a0
  83.     bsr        find_texture_index
  84.     move.w        d0,sky2_index
  85.     bmi.s        .n2
  86.     move.w        d0,current_sky
  87. .n2:    lea        ascii_sky3,a0
  88.     bsr        find_texture_index
  89.     move.w        d0,sky3_index
  90.     bmi.s        .n3
  91.     move.w        d0,current_sky
  92. .n3:    lea        ascii_sky4,a0
  93.     bsr        find_texture_index
  94.     move.w        d0,sky4_index
  95.     bmi.s        .go
  96.     move.w        d0,current_sky
  97. *-------------------------------------------------------*
  98. *    Replace wall texture references with indexes    *
  99. *-------------------------------------------------------*
  100. .go:    bsr        replace_textures
  101. *-------------------------------------------------------*
  102.     bsr        organise_patches
  103. *-------------------------------------------------------*
  104.     rts
  105.  
  106. *-------------------------------------------------------*
  107. *    Create tracking list for patches        *
  108. *-------------------------------------------------------*
  109. organise_patches:
  110. *-------------------------------------------------------*
  111.     bsr        build_directory_hash
  112.     Cconws        #ascii_locatepatch
  113.     move.l        pname_ptr,a3
  114.     move.l        pnamelist_array,a6
  115.     move.w        pname_count,d7
  116.     bra.s        .go
  117. .all:    move.l        a3,a0
  118.     bsr        locate_entry
  119. .cont:    move.l        d0,(a6)+
  120.     addq.l        #8,a3
  121. .go:    dbra        d7,.all
  122.     rts
  123.  
  124. *-------------------------------------------------------*
  125. *    Create hashtable to reduce search overheads    *
  126. *-------------------------------------------------------*
  127. build_flat_hash:
  128. *-------------------------------------------------------*
  129. *    Track down 'f_start' & 'f_end' markers        *
  130. *-------------------------------------------------------*
  131.     st        flats_present
  132.     lea        ascii_fstart,a0
  133.     bsr        place_marker
  134.     move.l        wad_mdirectory,flat_start
  135.     tst.w        d0
  136.     beq.s        .err
  137.     lea        ascii_fend,a0
  138.     push.l        all_directory
  139.     push.l        all_entries    
  140.     move.l        wad_mdirectory,all_directory
  141.     move.l        wad_mentries,all_entries    
  142.     bsr        place_marker
  143.     pop.l        all_entries
  144.     pop.l        all_directory
  145.     move.l        wad_mdirectory,flat_end
  146.     tst.w        d0
  147.     bne.s        .cont
  148. .err:    Cconws        #ascii_err_noflats
  149.     sf        flats_present
  150.     bra        .exit
  151. *-------------------------------------------------------*
  152. *    Create hashtable for all valid entries        *
  153. *-------------------------------------------------------*
  154. .cont:    bsr        empty_hash
  155.     move.l        flat_end,d7
  156.     move.l        flat_start,a0
  157.     sub.l        a0,d7
  158.     divu.l        #wd_len,d7
  159.     move.l        hash_array,a2
  160.     move.l        floating_array,a3
  161.     bra.s        .go
  162. *-------------------------------------------------------*
  163. .all:
  164. *-------------------------------------------------------*
  165.     movem.l        d1-d7/a0-a6,-(sp)
  166.     lea        wd_name(a0),a1
  167.     lea        ascii_sky,a0
  168.     bsr        strcmp_8
  169.     movem.l        (sp)+,d1-d7/a0-a6
  170.     tst.w        d0
  171.     beq.s        .nsky
  172. *-------------------------------------------------------*
  173. *    Keep track of sky index                *
  174. *-------------------------------------------------------*
  175.     move.l        a3,d0
  176.     sub.l        graphics_array,d0
  177.     lsr.l        #2,d0
  178.     move.w        d0,sky_index
  179. *-------------------------------------------------------*
  180. *    Generate hash index for entry            *
  181. *-------------------------------------------------------*
  182. .nsky:    lea        wd_name(a0),a1
  183.     bsr        hash_name
  184. *-------------------------------------------------------*
  185. *    Store reference in hash table            *
  186. *-------------------------------------------------------*
  187.     move.w        #max_hash-1,d4
  188. .find:    and.w        #max_hash-1,d1
  189.     tst.l        (a2,d1.w*4)
  190.     beq.s        .slot
  191.     addq.w        #1,d1
  192.     dbra        d4,.find
  193. .slot:    move.l        a3,(a2,d1.w*4)
  194. *-------------------------------------------------------*
  195. *    Store index & directory in reference list    *
  196. *-------------------------------------------------------*
  197.     move.l        a0,(a3)+
  198. *-------------------------------------------------------*
  199. *    Store type in cache slot            *
  200. *-------------------------------------------------------*
  201.     move.w        graphics_count,d4
  202.     lea        cache_slots,a1
  203.     mulu.w        #cache_slen,d4
  204.     move.w        #ctype_raw,cache_type(a1,d4.l)
  205.     addq.w        #1,flat_count
  206.     addq.w        #1,graphics_count
  207. *-------------------------------------------------------*
  208. .next:    lea        wd_len(a0),a0
  209. .go:    dbra        d7,.all
  210.     move.l        a3,floating_array
  211. .exit:    rts
  212.  
  213. *-------------------------------------------------------*
  214. *    Remove upper / lower names from sky linedefs    *
  215. *-------------------------------------------------------*
  216. fix_sky_textures:
  217. *-------------------------------------------------------*
  218.     Cconws        #ascii_fixsky
  219. *-------------------------------------------------------*
  220.     move.l        Line_Array,a2
  221.     move.l        Side_Array,a6
  222.     move.w        NumLines,d7
  223.     bra        .lines
  224. *-------------------------------------------------------*
  225. .line:    move.w        linedef_left(a2),d0
  226.     bmi        .err
  227.     mulu.w        #sidedef_len,d0
  228.     lea        (a6,d0.l),a4            ; left sidedef
  229.     move.w        linedef_right(a2),d0
  230.     bmi        .err
  231.     mulu.w        #sidedef_len,d0
  232.     lea        (a6,d0.l),a3            ; right sidedef
  233. *-------------------------------------------------------*
  234.     push.l        a6
  235. *-------------------------------------------------------*
  236.     move.l        Sector_Array,a0
  237.     move.w        sidedef_sector(a4),d0
  238.     mulu.w        #sector_len,d0
  239.     lea        (a0,d0.l),a6            ; left sector
  240.     move.w        sidedef_sector(a3),d0
  241.     mulu.w        #sector_len,d0
  242.     lea        (a0,d0.l),a5            ; right sector
  243. *-------------------------------------------------------*
  244.     lea        ascii_sky,a0
  245.     lea        sector_ctns(a5),a1
  246.     bsr        strcmp_8
  247.     tst.w        d0
  248.     beq.s        .no_upper_sky
  249.     lea        sector_ctns(a6),a1
  250.     bsr        strcmp_8
  251.     tst.w        d0
  252.     beq.s        .no_upper_sky
  253. *-------------------------------------------------------*
  254.     lea        sidedef_utns(a4),a0
  255.     bsr        sky_name
  256.     lea        sidedef_utns(a3),a0
  257.     bsr        sky_name
  258. *-------------------------------------------------------*
  259. .no_upper_sky:
  260. *-------------------------------------------------------*
  261.     lea        ascii_sky,a0
  262.     lea        sector_ftns(a5),a1
  263.     bsr        strcmp_8
  264.     tst.w        d0
  265.     beq.s        .no_lower_sky
  266.     lea        sector_ftns(a6),a1
  267.     bsr        strcmp_8
  268.     tst.w        d0
  269.     beq.s        .no_lower_sky
  270. *-------------------------------------------------------*
  271.     lea        sidedef_ltns(a4),a0
  272.     bsr        sky_name
  273.     lea        sidedef_ltns(a3),a0
  274.     bsr        sky_name
  275. *-------------------------------------------------------*
  276. .no_lower_sky:
  277. *-------------------------------------------------------*
  278.     pop.l        a6
  279. *-------------------------------------------------------*
  280. .err:    lea        linedef_len(a2),a2
  281. .lines:    dbra        d7,.line
  282.     rts
  283.  
  284.  
  285. *-------------------------------------------------------*
  286. *    Patch quick-alpha textures            *
  287. *-------------------------------------------------------*
  288. patch_alpha_textures:
  289. *-------------------------------------------------------*
  290.     Cconws        #ascii_patchalpha
  291.     move.l        Side_Array,a3
  292.     move.w        NumSides,d7
  293.     bra.s        .segs
  294. .seg:
  295. ;    lea        sidedef_utns(a3),a1
  296. ;    bsr        alpha_check
  297. ;    lea        sidedef_ltns(a3),a1
  298. ;    bsr        alpha_check
  299.     lea        sidedef_mtns(a3),a1
  300.     bsr        alpha_check
  301.     lea        sidedef_len(a3),a3
  302. .segs:    dbra        d7,.seg
  303.     rts
  304.  
  305. *-------------------------------------------------------*
  306. alpha_check:
  307. *-------------------------------------------------------*
  308.     lea        ascii_qalpha,a0
  309.     bsr        strcmp_8
  310.     tst.w        d0
  311.     beq.s        .not_alpha
  312. *-------------------------------------------------------*
  313. *    Alpha texture detected                *
  314. *-------------------------------------------------------*
  315.     move.w        #'~q',(a1)+
  316.     clr.w        (a1)+
  317.     clr.l        (a1)+
  318. *-------------------------------------------------------*
  319. .not_alpha:
  320. *-------------------------------------------------------*
  321.     rts
  322.  
  323. *-------------------------------------------------------*
  324. *    Trash texture name                *
  325. *-------------------------------------------------------*
  326. sky_name:
  327. *-------------------------------------------------------*
  328.     move.w        #'~s',(a0)+
  329.     clr.w        (a0)+
  330.     clr.l        (a0)+
  331.     rts
  332.  
  333. *-------------------------------------------------------*
  334. *    Replace flat names with quick-index values    *
  335. *-------------------------------------------------------*
  336. replace_flats:
  337. *-------------------------------------------------------*
  338.     bsr        build_flat_hash
  339.     Cconws        #ascii_replaceflat
  340.     move.l        Sector_Array,a3
  341.     move.w        NumSectors,d7
  342.     bra.s        .segs
  343. .seg:    lea        sector_ctns(a3),a0
  344.     bsr.s        replace_flatname
  345.     lea        sector_ftns(a3),a0
  346.     bsr.s        replace_flatname
  347.     lea        sector_len(a3),a3
  348. .segs:    dbra        d7,.seg
  349.     rts
  350.  
  351. *-------------------------------------------------------*
  352. *    Replace flat name with quick-index        *
  353. *-------------------------------------------------------*
  354. replace_flatname:
  355. *-------------------------------------------------------*
  356.     cmp.b        #'-',(a0)
  357.     beq.s        .none
  358.     move.l        a0,a1
  359.     bsr        hash_name
  360.     move.l        hash_array,a2
  361.     move.w        #max_hash-1,d4
  362. .find:    and.w        #max_hash-1,d1
  363.     move.l        (a2,d1.w*4),d5
  364.     beq.s        .err
  365.     move.l        d5,a4
  366.     move.l        (a4),a1
  367.     lea        wd_name(a1),a1
  368.     bsr        strcmp_8
  369.     tst.w        d0
  370.     beq.s        .cont
  371.     sub.l        graphics_array,d5
  372.     lsr.l        #2,d5
  373.     move.w        d5,(a0)+
  374.     bra.s        .done
  375. .cont:    addq.w        #1,d1
  376.     dbra        d4,.find
  377. .err:    clr.w        (a0)+
  378.     bra.s        .done
  379. .none:    move.w        #-1,(a0)+
  380. .done:    clr.w        (a0)+
  381.     clr.l        (a0)+
  382.     rts
  383.  
  384. *-------------------------------------------------------*
  385. *    Load PNAME resource from WAD            *
  386. *-------------------------------------------------------*
  387. read_pnames:
  388. *-------------------------------------------------------*
  389.     Cconws        #ascii_readpnames
  390.     lea        ascii_pnames,a0
  391.     bsr        load_resource
  392.     tst.l        d0
  393.     beq        err_missing
  394.     imov.l        (a6)+,d0
  395.     move.w        d0,pname_count
  396.     move.l        a6,pname_ptr
  397.     rts
  398.  
  399. *-------------------------------------------------------*
  400. *    Process texture directory            *
  401. *-------------------------------------------------------*
  402. add_textures:
  403. *-------------------------------------------------------*
  404.     bsr        load_resource
  405.     tst.l        d0
  406.     beq.s        .err1
  407.     move.l        a6,resource_ptr
  408.     move.l        texture_array,a4
  409.     move.l        floating_array,a5
  410.     imov.l        (a6)+,d6
  411.     bra.s        .texs
  412. .tex:    imov.l        (a6)+,a0
  413.     add.l        resource_ptr,a0
  414.     bsr        store_texturedef    
  415.     addq.w        #1,graphics_count
  416.     addq.w        #1,texture_count
  417. .texs:    dbra        d6,.tex
  418.     move.l        a5,floating_array
  419.     move.l        a4,texture_array
  420.     move.l        resource_ptr,d0
  421.     jsr        deallocate_chunk
  422.     st        textures_present
  423. .err1:    rts
  424.  
  425. *-------------------------------------------------------*
  426. *    Transfer texture definition to new array    *
  427. *-------------------------------------------------------*
  428. store_texturedef:
  429. *-------------------------------------------------------*
  430. *    Store type in cache slot            *
  431. *-------------------------------------------------------*
  432.     move.w        graphics_count,d0
  433.     lea        cache_slots,a1
  434.     mulu.w        #cache_slen,d0
  435.     move.w        #ctype_texture,cache_type(a1,d0.l)
  436. *-------------------------------------------------------*
  437. *    Record this texture in graphics array        *
  438. *-------------------------------------------------------*
  439.     move.l        a4,(a5)+
  440. *-------------------------------------------------------*
  441. *    Create texture definition            *
  442. *-------------------------------------------------------*
  443.     movem.l        wt_name(a0),d0/d1
  444.     movem.l        d0/d1,tex_name(a4)
  445.     move.w        graphics_count,tex_index(a4)
  446.     imov.w        wt_width(a0),tex_width(a4)
  447.     imov.w        wt_height(a0),tex_height(a4)
  448.     imov.w        wt_patches(a0),d1
  449.     move.w        d1,tex_patches(a4)
  450.     lea        wt_len(a0),a0
  451.     lea        tex_len(a4),a4
  452.     bra.s        .copys
  453. .copy:    imov.w        wtp_xoff(a0),texp_xoff(a4)
  454.     imov.w        wtp_yoff(a0),texp_yoff(a4)
  455.     imov.w        wtp_index(a0),texp_index(a4)
  456.     lea        wtp_len(a0),a0
  457.     lea        texp_len(a4),a4
  458. .copys:    dbra        d1,.copy
  459.     rts
  460.  
  461. *-------------------------------------------------------*
  462. *    Create hashtable to reduce search overheads    *
  463. *-------------------------------------------------------*
  464. build_texture_hash:
  465. *-------------------------------------------------------*
  466.     move.l        #texture_space,texture_array
  467.     bsr        empty_hash
  468.     move.l        hash_array,a2
  469.     move.l        texturelist_array,a0
  470.     move.w        texture_count,d7
  471.     bra.s        .hashs
  472. .next:    move.l        (a0)+,a1
  473.     move.l        a1,a3
  474.     bsr.s        hash_name
  475.     move.w        #max_hash-1,d4
  476. .find:    and.w        #max_hash-1,d1
  477.     tst.l        (a2,d1.w*4)
  478.     beq.s        .slot
  479.     addq.w        #1,d1
  480.     dbra        d4,.find
  481. .slot:    move.l        a3,(a2,d1.w*4)
  482. .hashs:    dbra        d7,.next
  483.     rts
  484.  
  485. *-------------------------------------------------------*
  486. *    Find texture index using hashtable        *
  487. *-------------------------------------------------------*
  488. find_texture_index:
  489. *-------------------------------------------------------*
  490.     move.l        a0,a1
  491.     bsr        hash_name
  492.     move.l        hash_array,a2
  493.     move.w        #max_hash-1,d4
  494. .find:    and.w        #max_hash-1,d1
  495.     move.l        (a2,d1.w*4),d0
  496.     beq.s        .none
  497.     move.l        d0,a1
  498.     bsr        strcmp_8
  499.     tst.w        d0
  500.     beq.s        .cont
  501.     move.w        tex_index(a1),d0
  502.     bra.s        .done
  503. .cont:    addq.w        #1,d1
  504.     dbra        d4,.find
  505. .none:    moveq        #-1,d0
  506. .done:    rts
  507.  
  508. *-------------------------------------------------------*
  509. *    Generate hash index for 8-character name    *
  510. *-------------------------------------------------------*
  511. hash_name:
  512. *-------------------------------------------------------*
  513.     moveq        #0,d1
  514.     moveq        #1,d3
  515.     moveq        #8-1,d2
  516. .all:    moveq        #0,d0
  517.     move.b        (a1)+,d0
  518.     beq.s        .hash
  519.     fixcase        d0
  520.     sub.w        #'0',d0
  521.     muls.w        d3,d0
  522.     add.l        d0,d1
  523.     addq.w        #8,d3
  524.     dbra        d2,.all
  525. .hash:    and.w        #max_hash-1,d1
  526.     rts
  527.     
  528. *-------------------------------------------------------*
  529. *    Replace texture names with quick-index values    *
  530. *-------------------------------------------------------*
  531. replace_textures:        
  532. *-------------------------------------------------------*
  533.     Cconws        #ascii_replacetex
  534.     move.l        Side_Array,a3
  535.     move.w        NumSides,d7
  536.     bra.s        .segs
  537. .seg:    lea        sidedef_utns(a3),a0
  538.     bsr.s        replace_texname
  539.     lea        sidedef_ltns(a3),a0
  540.     bsr.s        replace_texname
  541.     lea        sidedef_mtns(a3),a0
  542.     bsr.s        replace_texname
  543.     lea        sidedef_len(a3),a3
  544. .segs:    dbra        d7,.seg
  545.     rts
  546.  
  547. *-------------------------------------------------------*
  548. *    Replace texture name with quick-index        *
  549. *-------------------------------------------------------*
  550. replace_texname:
  551. *-------------------------------------------------------*
  552.     cmp.b        #'-',(a0)
  553.     beq.s        no_texture
  554. *-------------------------------------------------------*
  555.     cmp.b        #'~',(a0)
  556.     beq.s        special_texture
  557. *-------------------------------------------------------*
  558. normal_texture:
  559. *-------------------------------------------------------*
  560.     move.l        a0,a1
  561.     bsr        hash_name
  562.     move.l        hash_array,a2
  563.     move.w        #max_hash-1,d4
  564. .find:    and.w        #max_hash-1,d1
  565.     move.l        (a2,d1.w*4),d0
  566.     beq.s        missing_texture
  567.     move.l        d0,a1
  568.     bsr        strcmp_8
  569.     tst.w        d0
  570.     beq.s        .cont
  571.     move.w        tex_index(a1),(a0)+
  572.     bra.s        texture_done
  573. .cont:    addq.w        #1,d1
  574.     dbra        d4,.find
  575. *-------------------------------------------------------*
  576. missing_texture:
  577. *-------------------------------------------------------*
  578.     move.w        #texcode_none,(a0)+
  579. ;    clr.w        (a0)+
  580.     bra.s        texture_done
  581. *-------------------------------------------------------*
  582. special_texture:
  583. *-------------------------------------------------------*
  584.     cmp.w        #'~s',(a0)
  585.     beq.s        .sky
  586.     cmp.w        #'~q',(a0)
  587.     beq.s        .qal
  588.     bra        missing_texture
  589. *-------------------------------------------------------*
  590. *    Sky texture                    *
  591. *-------------------------------------------------------*
  592. .sky:    move.w        #texcode_sky,(a0)+
  593.     bra.s        texture_done
  594. *-------------------------------------------------------*
  595. *    Quick-alpha texture                *
  596. *-------------------------------------------------------*
  597. .qal:    move.w        #texcode_qalpha,(a0)+
  598.     bra.s        texture_done
  599. *-------------------------------------------------------*
  600. no_texture:
  601. *-------------------------------------------------------*
  602.     move.w        #texcode_none,(a0)+
  603. *-------------------------------------------------------*
  604. texture_done:
  605. *-------------------------------------------------------*
  606.     clr.w        (a0)+
  607.     clr.l        (a0)+
  608.     rts
  609.  
  610. *-------------------------------------------------------*
  611. *    Wipe hashtable                    *
  612. *-------------------------------------------------------*
  613. empty_hash:
  614. *-------------------------------------------------------*
  615.     move.l        hash_array,a0
  616.     moveq        #0,d1
  617.     move.w        #max_hash-1,d0
  618. .clr:    move.l        d1,(a0)+
  619.     dbra        d0,.clr
  620.     rts
  621.  
  622. *-------------------------------------------------------*
  623. *    Simple mainloop for texture browser        *
  624. *-------------------------------------------------------*
  625. texture_loop:    
  626. *-------------------------------------------------------*
  627.     push.w        window_size
  628.     move.w        #window_max,window_size
  629.     bsr        select_window
  630.     bsr        adjust_scanlines
  631.  
  632.     moveq        #0,d0
  633.     lea        key_buffer,a6
  634.     bra        .tok
  635. .loop:
  636.     ifd        debuggable
  637.     pushall
  638.     bsr        read_key
  639.     popall
  640.     endc
  641.     tst.b        right_key(a6)
  642.     beq.s        .n1
  643.     addq.w        #1,d0
  644.     cmp.w        texture_count,d0
  645.     bmi.s        .tok
  646.     move.w        texture_count,d0
  647.     subq.w        #1,d0
  648. .tok:    pushall
  649.     move.b        #1,refresh
  650.     move.l        ScreenPhy,a0
  651.     bsr        clearscreen
  652.     popall
  653.     bsr        render_texture
  654. .n1:    tst.b        left_key(a6)
  655.     beq.s        .n2
  656.     subq.w        #1,d0
  657.     bpl.s        .ok1
  658.     moveq        #0,d0
  659. .ok1:    pushall
  660.     move.b        #1,refresh
  661.     move.l        ScreenPhy,a0
  662.     bsr        clearscreen
  663.     popall
  664.     bsr        render_texture
  665. .n2:    tst.b        text_key(a6)
  666.     beq        .loop
  667.     pop.w        window_size
  668.     bsr        select_window
  669.     rts
  670.  
  671. *-------------------------------------------------------*
  672.             bsslong
  673. *-------------------------------------------------------*
  674.  
  675. hash_array:        ds.l    1            ; misc texture pointers
  676.  
  677. graphics_array:        ds.l    1
  678. floating_array:        ds.l    1
  679. flatlist_array:        ds.l    1
  680. texturelist_array:    ds.l    1
  681. pnamelist_array:    ds.l    1
  682. texture_array:        ds.l    1
  683. flat_start:        ds.l    1
  684. flat_end:        ds.l    1
  685. patch_start:        ds.l    1
  686. patch_end:        ds.l    1
  687. resource_ptr:        ds.l    1
  688. pname_ptr:        ds.l    1
  689.  
  690. hash_space:        ds.l    max_hash        ; space for texture arrays
  691. graphics_space:        ds.l    max_graphics        ; and quicksearch hashtable
  692. pnamelist_space:    ds.l    max_textures
  693.  
  694. texture_space:        ds.b    (tex_len+(texp_len*4))*max_textures
  695.  
  696. graphics_count:        ds.w    1
  697. flat_count:        ds.w    1
  698. texture_count:        ds.w    1            
  699. pname_count:        ds.w    1            ; misc array sizes
  700.  
  701. flat_index:        ds.w    1            ; misc flat index variables
  702. sky_index:        ds.w    1
  703. current_sky:        ds.w    1
  704. sky1_index:        ds.w    1
  705. sky2_index:        ds.w    1
  706. sky3_index:        ds.w    1
  707. sky4_index:        ds.w    1
  708.  
  709. textures_present:    ds.b    1            ; flags for missing resources
  710. flats_present:        ds.b    1
  711. patches_present:    ds.b    1
  712.  
  713. *-------------------------------------------------------*
  714.             txtlong
  715. *-------------------------------------------------------*
  716.